package com.example.demo1.utils;

import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import org.json.JSONTokener;

import android.util.Log;

public class ServerUtils {
	public static String basePath = "http://192.168.49.100:8080/demo";
	private static final String TAG = "ServerUtils";
	public static JSONObject invoke(String url,List<NameValuePair> nameValuePairs){
		HttpPost httpPost = HttpUtils.getPost(basePath+url,nameValuePairs);
		if(httpPost!=null){
			String string = HttpUtils.getString(httpPost);
			if(string!=null){
				JSONTokener jsonParser = new JSONTokener(string);
				try {
					JSONObject result2 = (JSONObject) jsonParser.nextValue();
					return result2;
				} catch (Exception e) {
					Log.e(TAG, e.getMessage());
				}
			}
		}
		return null;
	}
}
